import { http } from "@/utils/http";

type ResultTable = {
  [x: string]: any;
  total?: number;
  data?: Array<any>;
};
type ResultByRuleId = {
  id?: string;
  ruleId?: string;
  ruleName?: string;
  ruleDesc?: string;
  shieldCondition?: string;
  shieldPointList?: Array<any>;
  isForeverShield?: string; //是否永久屏蔽：YES - 是；NO - 否
  timeRangeType?: string; //时间范围类型：ABSOLUTE - 绝对；RELATIVE - 相对
  startTime?: string; //开始时间(date-time)
  endTime?: string; //结束时间(date-time)
  enableStatus?: string; //启用状态：ON：启用；OFF：停用
  status?: string; //记录状态：VALID- 有效；INVALID - 无效
  createTime?: string;
  updateTime?: string;
};
type ResultByPost = {
  [x: string]: any;
};
type Result = {
  success: boolean;
  data: Array<any>;
};
//查询业务报警列表
export const queryById = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/business/query`, {
    data
  });
};

// 新增报警备注
export const addRemarkApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/remark/create`, {
    data
  });
};

// 删除报警备注
export const delRemarkApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/remark/update`, {
    data
  });
};

// 报警历史
export const getRemarkHistoryApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/remark/query`, {
    data
  });
};

// ack
export const handleAckApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/business/status/update`, {
    data
  });
};

// 报警详情
export const handleAlertDetailApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/business/get`, {
    data
  });
};

// 通讯报警列表
export const queryMsgAlertApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/communication/query`, {
    data
  });
};

// 通讯报警处置
export const handleMsgAlertUpdateApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/communication/update`, {
    data
  });
};

// 通讯报警详情
export const handleMsgAlertDetailApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/communication/get`, {
    data
  });
};

// 推送规则列表
export const queryRulesListApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/configuration/query`, {
    data
  });
};

// 推送规则新增
export const handleRulesAddApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/configuration/create`, {
    data
  });
};

// 推送规则详情
export const handleRulesDetailApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/configuration/get`, {
    data
  });
};

// 推送规则编辑
export const handleRulesUpdateApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/configuration/update`, {
    data
  });
};

// 推送规则删除
export const handleRulesDeleteApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/configuration/delete`, {
    data
  });
};

// 报警数量
export const queryAlarmCount = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/count`, {
    data
  });
};

/**  报警模板相关接口 */
// 模板列表
export const queryTemplateListApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/template/page`, {
    data
  });
};

// 删除模板
export const deleteTemplateApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/template/delete`, {
    data
  });
};

// 新增模板
export const addTemplateApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/template/save`, {
    data
  });
};

// 更新模板
export const updateTemplateApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/template/update`, {
    data
  });
};

// 模板详情
export const detailTemplateApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/template/get`, {
    data
  });
};

// 报警枚举
export const queryAlarmEnum = () => {
  return http.request("get", `/sharing/api/v1/alarm/enum/query`);
};

/**  报警屏蔽规则相关接口 */
// 屏蔽规则列表
export const queryShieldRulesListApi = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/shieldRule/page`, {
    data
  });
};

// 删除屏蔽规则
export const deleteShieldRulesApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/shieldRule/delete`, {
    data
  });
};

// 新增屏蔽规则
export const addShieldRulesApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/shieldRule/save`, {
    data
  });
};

// 更新屏蔽规则
export const updateShieldRulesApi = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/shieldRule/update`, {
    data
  });
};

// 个人屏蔽规则列表
export const queryShieldRuleByPerson = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/shieldRule/person/query`, {
    data
  });
};

// 新增个人屏蔽
export const addShieldRuleByPerson = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/shieldRule/person/create`, {
    data
  });
};

// 移除个人屏蔽
export const removeShieldRuleByPerson = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/shieldRule/person/delete`, {
    data
  });
};

export const queryShieldRuleByRuleId = (data?: Record<string, any>) => {
  return http.request<ResultByRuleId>("post", `/sharing/api/v1/alarm/shieldRule/get`, {
    data
  });
};
export const queryPostList = (data?: Record<string, any>) => {
  return http.request<ResultByPost>("post", `/account/api/v1/user/position/query`, {
    data
  });
};
export const getTemplList = (params?: Record<string, any>) => {
  return http.request<Result>(
    "get",
    `/sharing/api/v1/alarm/template/variable/get
`,
    { params }
  );
};

// 报警分析数据获取
export const queryChartData = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/alarmAnalysis`, {
    data
  });
};

// 报警分析数据获取--区域漏液
export const queryLeakChartData = (data?: Record<string, any>) => {
  return http.request<any[]>("post", `/sharing/api/v1/alarm/leakAlarmList`, {
    data
  });
};

// 报警分析数据获取--系统报警列表
export const querySystemChartData = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/systemAlarmList`, {
    data
  });
};

// 报警列表-下线点位
export const downPoint = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/point/offline`, {
    data
  });
};

// 报警列表-点位列表
export const getPointList = (data?: Record<string, any>) => {
  return http.request("post", `/sharing/api/v1/alarm/point/query`, {
    data
  });
};
